package com.passengerflowmanagementsystem.web.controller.em;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.passengerflowmanagementsystem.common.annotation.Log;
import com.passengerflowmanagementsystem.common.core.controller.BaseController;
import com.passengerflowmanagementsystem.common.core.domain.AjaxResult;
import com.passengerflowmanagementsystem.common.enums.BusinessType;
import com.passengerflowmanagementsystem.statistics.domain.EmGetway;
import com.passengerflowmanagementsystem.statistics.service.IEmGetwayService;
import com.passengerflowmanagementsystem.common.utils.poi.ExcelUtil;
import com.passengerflowmanagementsystem.common.core.page.TableDataInfo;

/**
 * 网关Controller
 * 
 * @author sheng
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/em/getway")
public class EmGetwayController extends BaseController
{
    @Autowired
    private IEmGetwayService emGetwayService;

    /**
     * 查询网关列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EmGetway emGetway)
    {
        startPage();
        List<EmGetway> list = emGetwayService.selectEmGetwayList(emGetway);
        return getDataTable(list);
    }

    /**
     * 导出网关列表
     */
    @Log(title = "网关", businessType = BusinessType.EXPORT)
    @PostMapping("/导出网关列表")
    public void export(HttpServletResponse response, EmGetway emGetway)
    {
        List<EmGetway> list = emGetwayService.selectEmGetwayList(emGetway);
        ExcelUtil<EmGetway> util = new ExcelUtil<EmGetway>(EmGetway.class);
        util.exportExcel(response, list, "网关数据");
    }

    /**
     * 获取网关详细信息
     */
    @GetMapping(value = "/{getwayId}")
    public AjaxResult getInfo(@PathVariable("getwayId") Long getwayId)
    {
        return success(emGetwayService.selectEmGetwayByGetwayId(getwayId));
    }

    /**
     * 新增网关
     */
    @Log(title = "新增网关", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmGetway emGetway)
    {
        return toAjax(emGetwayService.insertEmGetway(emGetway));
    }

    /**
     * 修改网关
     */
    @Log(title = "修改网关", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmGetway emGetway)
    {
        return toAjax(emGetwayService.updateEmGetway(emGetway));
    }

    /**
     * 删除网关
     */
    @Log(title = "删除网关", businessType = BusinessType.DELETE)
	@DeleteMapping("/{getwayIds}")
    public AjaxResult remove(@PathVariable Long[] getwayIds)
    {
        return toAjax(emGetwayService.deleteEmGetwayByGetwayIds(getwayIds));
    }
}
